package com.x.crm.service;

import com.alibaba.dubbo.config.annotation.Service;
import com.x.crm.dao.CustomerDao;
import com.x.crm.model.Customer;
import com.x.crm.rpc.CustomerRpcService;
import com.x.framework.exception.BusinessException;
import com.x.framework.exception.ExceptionCode;
import com.x.framework.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Created by x on 2017/11/13.
 */
@Component
@Service(interfaceName = "com.x.crm.rpc.CustomerRpcService", timeout = 60000)
public class CustomerService extends BaseService implements CustomerRpcService {

    @Autowired
    private CustomerDao customerDao;

    public List<Customer> selectCustomerList(Customer customer) {
        try {
            return customerDao.selectCustomerList(customer);
        } catch (Exception e) {
            throw new BusinessException(ExceptionCode.EXCEPTION_CODE0006, e);
        }
    }

    public Customer insertCustomer(Customer customer) {
        try {
            return this.insert(customer);
        } catch (Exception e) {
            throw new BusinessException(ExceptionCode.EXCEPTION_CODE0007, e);
        }
    }

    public int updateCustomer(Customer customer) {
        try {
            return this.update(customer);
        } catch (Exception e) {
            throw new BusinessException(ExceptionCode.EXCEPTION_CODE0007, e);
        }
    }

//    public List<Customer> selectOwnerCustomerList(Customer customer, Intention intention) {
//        try {
//            return customerDao.selectOwnerCustomerList(customer,intention);
//        } catch (Exception e) {
//            throw new BusinessException(ExceptionCode.EXCEPTION_CODE0006, e);
//        }
//    }


}
